package com.set.treeset;

import java.util.*;

class Emp{
	private int id;
	private String name;
	public Emp(){}
	public Emp(int id,String name){
		this.id=id;
		this.name=name;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String toString(){
		return id+"\t"+name;
	}
	@Override
	public int hashCode() {
		
		return id;
	}
	@Override
	public boolean equals(Object obj) {
		return true;
	}
	
}
public class Example1 {
public static void main(String[] args) {
	Emp e1=new Emp(101, "sri");
	Emp e3=new Emp(103, "sri");
	Emp e2=new Emp(102, "nivas");
	TreeSet s=new TreeSet();
	s.add(e1);
	s.add(e2);
	s.add(e3);
	Iterator itr=s.iterator();
	while(itr.hasNext()){
		Emp em=(Emp)itr.next();
		System.out.println(em);
	}
	
}
}
